create or replace view vac_page_templates_4_1 as
with pt as
(
 select
    workspace,
    workspace_display_name,
    application_id,
    application_name,
    template_name,
--
    ac_utils.hs(header_template)                     header_template_hs,
    dbms_lob.substr(header_template, 4000, 1)        header_template_sr1,
    dbms_lob.substr(header_template, 4000, 4000+1 )  header_template_sr2,
    dbms_lob.substr(header_template, 4000, 8000+1 )  header_template_sr3,
    dbms_lob.substr(header_template, 4000, 12000+1)  header_template_sr4,
--
    ac_utils.hs(page_body)                     page_body_hs,
    dbms_lob.substr(page_body, 4000, 1)        page_body_sr1,
    dbms_lob.substr(page_body, 4000, 4000+1 )  page_body_sr2,
    dbms_lob.substr(page_body, 4000, 8000+1 )  page_body_sr3,
    dbms_lob.substr(page_body, 4000, 12000+1)  page_body_sr4,
--
    ac_utils.hs(footer_template)                     footer_template_hs,
    dbms_lob.substr(footer_template, 4000, 1)        footer_template_sr1,
    dbms_lob.substr(footer_template, 4000, 4000+1 )  footer_template_sr2,
    dbms_lob.substr(footer_template, 4000, 8000+1 )  footer_template_sr3,
    dbms_lob.substr(footer_template, 4000, 12000+1)  footer_template_sr4,
 --
    success_message,
    current_tab,
    current_tab_font_attr,
    non_current_tab,
    non_current_tab_font_attr,
    current_image_tab,
    non_current_image_tab,
    current_parent_tab,
    current_parent_tab_attr,
    noncurrent_parent_tab,
    noncurrent_parent_tab_attr,
    navigation_bar,
    navbar_entry,
    message,
    multicolumn_region_table_attr,
    error_page_template,
    is_subscribed,
    subscribed_from,
    theme_number,
    theme_class,
    last_updated_by,
    last_updated_on,
    translatable,
    mobile,
    component_comment,
    template_id,
    component_signature
 from apex_application_temp_page
)
select
      workspace,
      workspace_display_name,
      application_id,
      application_name,
      template_name,
      theme_number,
      theme_class,
      last_updated_by,
      last_updated_on,
      template_id,
      component_signature,
      u_name,
      u_value,
      'APEX_APPLICATION_TEMP_PAGE' src_view_name,
      to_clob(header_template_sr1) || to_clob(header_template_sr2)
      || to_clob(header_template_sr3) || to_clob(header_template_sr4) header_template_sr,
      to_clob(page_body_sr1) || to_clob(page_body_sr2)
      || to_clob(page_body_sr3) || to_clob(page_body_sr4) page_body_sr,
      to_clob(footer_template_sr1) || to_clob(footer_template_sr2)
      || to_clob(footer_template_sr3) || to_clob(footer_template_sr4) footer_template_sr
from
(
  select
      workspace,
      workspace_display_name,
      application_id,
      application_name,
      template_name,
      theme_number,
      theme_class,
      template_id,
      component_signature,
      last_updated_by,
      last_updated_on,
      u_name,
      u_value,
      header_template_sr1,
      header_template_sr2,
      header_template_sr3,
      header_template_sr4,
      page_body_sr1,
      page_body_sr2,
      page_body_sr3,
      page_body_sr4,
      footer_template_sr1,
      footer_template_sr2,
      footer_template_sr3,
      footer_template_sr4
  from pt
   UNPIVOT INCLUDE NULLS (
       u_value
       FOR    u_name
       IN
       (
          header_template_hs,
          page_body_hs,
          footer_template_hs,
          success_message,
          current_tab,
          current_tab_font_attr,
          non_current_tab,
          non_current_tab_font_attr,
          current_image_tab,
          non_current_image_tab,
          current_parent_tab,
          current_parent_tab_attr,
          noncurrent_parent_tab,
          noncurrent_parent_tab_attr,
          navigation_bar,
          navbar_entry,
          message,
          multicolumn_region_table_attr,
          error_page_template,
          is_subscribed,
          subscribed_from,
          translatable,
          mobile,
          component_comment
       )
   )
) t;

